var express=require('express');
var bodyParser = require('body-parser');
var routes=require(process.cwd()+"/server/routes.js");
var accessToken=require(process.cwd()+"/server/util/accessToken.js");
var menu=require(process.cwd()+"/server/util/setMenu.js");




// see https://github.com/expressjs/body-parser
// 添加 body-parser 中间件就可以了
var app=express();

app.use(bodyParser.urlencoded({extended: false}));
//app.use(bodyParser.json());


routes.setRoutes(app);
accessToken.startTokenCycle();
menu.createMenu();

app.use(express.static(process.cwd() + '/web'));
app.listen((process.env.VCAP_APP_PORT || 80), null);
console.log('listen in '+(process.env.VCAP_APP_PORT || 80));